import { GoodsItem } from "../../common/GoodsItem";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ItemMenuRegister } from "../../common/menu/ItemMenuRegister";
import { ItemData } from "../../../resource/info/ItemData";
type int = number;
//class MountEquipBaseItem
    
    export  class MountEquipBaseItem extends GoodsItem
    {
        constructor()
        {
            super();
            this.initView();
            this.initListener();
            return;
        }

        /* internal  */initView(): void
        {
            this.bm = ObjCreate.createBitmap("", -2, -3);
            LoaderHelp.addResCallBack(ResFileConst.mountEquip, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._loaded = true;
            this.setequipNullBm(this._equipType);
            return;
        }

        /* internal  */setequipNullBm(arg1: int): void
        {
            if (this._loaded) 
            {
                if (arg1 > 0 && arg1 < 5) 
                {
                    this.bm.bitmapData = GlobalClass.getBitmapData("mouintEquip_" + arg1);
                }
                else 
                {
                    this.bm.bitmapData = null;
                }
            }
            this.addChild(this.bm);
            return;
        }

        /* internal  */initListener(): void
        {
            this.addEventListener(flash.events.MouseEvent.CLICK, this.clickHandler, false, 9999);
            return;
        }

        /* internal  */clickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.ctrlKey) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ChatShowItem, itemData));
                arg1.stopImmediatePropagation();
                ItemMenuRegister.hideOpList();
            }
            return;
        }

        public /* override */ set itemData(arg1: ItemData)
        {
            super.itemData = arg1;
            if (arg1) 
            {
                ItemMenuRegister.register(this, arg1);
            }
            else 
            {
                ItemMenuRegister.unRegister(this);
            }
            return;
        }

        public setEquipType(arg1: int): void
        {
            this.setequipNullBm(arg1);
            return;
        }

        /* internal */ /* var */bm: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_equipType: int;

        /* internal */ /* var */_loaded: Boolean;
    }
